package in.wenwen.service.impl;

import in.wenwen.entity.LogUri;
import in.wenwen.service.IIpService;
import in.wenwen.service.ILogUriService;
import in.wenwen.util.UserManage;

import org.jiucheng.aop.Aop;
import org.jiucheng.ioc.annotation.Inject;
import org.jiucheng.ioc.annotation.Service;
import org.jiucheng.orm.interceptor.Close;
import org.jiucheng.orm.interceptor.Tx;
import org.jiucheng.plugin.db.BaseServiceImpl;

@Service("logUriService")
@Aop(Close.class)
public class LogUriServiceImpl extends BaseServiceImpl implements ILogUriService {
    
    @Inject
    private IIpService ipService;
    
    @Aop(Tx.class)
    public void saveLogUri(String pathInfo, String ip) {
    	ip = "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
        LogUri logUri = new LogUri();
        logUri.setWebappId(UserManage.getWebappId());
        logUri.setUri(pathInfo);
        logUri.setDomain(UserManage.getDomain());
        logUri.setIp(ip);
        //logUri.setIpName(ipService.getName(IpUtil.toLong(ip)));
        logUri.setIpName("");
        logUri.setCreateDatetime(UserManage.getReceiveDatetime());
        logUri.setModifyDatetime(UserManage.getReceiveDatetime());
        save(logUri);
    }
}
